home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9220 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.5 KB  |  72 lines

  1. Newsgroups: comp.lang.c++
  2. Path: netcom.com!marnold
  3. From: marnold@netcom.com (Matt Arnold)
  4. Subject: Re: Is there a standard for * and & placement style?
  5. Message-ID: <marnoldDnJ2xz.KsM@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. References: <3128BD31.4AF8@wildfire.com> <marnoldDn27q9.Is0@netcom.com> <4gckd5$bc7@clarknet.clark.net> <marnoldDn63vB.H6n@netcom.com> <4gk1b8$mtm@werple.net.au> <marnoldDn9u0A.GAD@netcom.com> <4gumu0$7c9@werple.net.au>
  8. Date: Thu, 29 Feb 1996 08:15:35 GMT
  9. Sender: marnold@netcom23.netcom.com
  10.  
  11. davidw@werple.net.au (David White) writes:
  12.  
  13. >marnold@netcom.com (Matt Arnold) writes:
  14.  
  15.  
  16. >>...is a "special case" for the "char *"-style, simply highlights that the
  17. >>style, IMO, is conceptually inconsistent.  Certainly, the function itself 
  18. >>doens't have pointer-ness (although, as for as the language it concerned, it 
  19. >>resovles to an expression that does) and so it doesn't seem quite right to 
  20. >>associate the * with the function name.  It seems inconsistent that you 
  21. >>would make this concession, but turn around and insist the "char *p" makes 
  22. >>sense for the declaration of p.
  23.  
  24. >It wasn't a concession. I would use 'char *foo()'. I was just saying that
  25. >I can understand why some people prefer 'char* foo()' (and 'char* p').
  26.  
  27. I see.
  28.  
  29. >I don't want to drag this on, because it doesn't bother me if others use
  30. >the 'char* p' form, but I don't think my point came across too well.
  31. >My main point concerned you and another poster suggesting that the form:
  32. >    char* p, q;
  33. >should declare both 'p' and 'q' to be char*. I
  34.  
  35. I didn't suggest that.  I pointed out that I personally never use that 
  36. form because I find it visually inconsistent and potentially bug-prone
  37. (for me anyway).
  38.  
  39. I suppose it follows that I never use mutliple code statements on a
  40. single line, delimited by commas, either.  Yuck!
  41.  
  42. > was just trying to demonstrate
  43. >that, without making special rules for '*' (and '&'), this doesn't fit in
  44. >with the language. As far as the compiler is concerned, *, &, [],
  45. >() are operators that apply to an operand. In its parsing, it treats
  46. >them that way whether it is an expression or a declaration. It is only
  47. >because '*' happens to be a pre-operand operator that you are able
  48. >to place the '*' with the 'char'. That's why I prefer the 'char *p'
  49. >(and 'char *foo()') form; I just follow the same rules as the compiler
  50. >for everything. I don't see any fundamental difference between
  51. >'array of char' and 'pointer to char'; arrays and pointers are both
  52. >types derived from some other, but you can't write 'char[10] p', simply
  53. >because thej[10] is on the wrong side of 'p'.
  54.  
  55. Well, as I said before, this is one of those preference things, just like 
  56. where curly braces should go.
  57.  
  58. I still think it makes more sense to think of declaration statements as
  59. types and instances of those types.  In a declaration, I'd rather see * 
  60. as an operator on the type rather than on the instance.  Because the 
  61. "loose" multiple-instance per type declaration rules interfere with this 
  62. view, I never use that form.
  63.  
  64. Regards,
  65. -------------------------------------------------------------------------
  66. Matt Arnold                       |        | ||| | |||| |  | | || ||
  67. marnold@netcom.com                |        | ||| | |||| |  | | || ||
  68. Boston, MA                        |      0 | ||| | |||| |  | | || ||
  69. 617.389.7384 (h) 617.576.2760 (w) |        | ||| | |||| |  | | || ||
  70. C++, MIDI, Win32/95 developer     |        | ||| 4 3 1   0 8 3 || ||
  71. -------------------------------------------------------------------------
  72.